package com.enlorenz.core.queue.proc;

import java.util.Collection;

import com.enlorenz.common.util.DataDetUtils;
import com.enlorenz.core.queue.transfer.imp.NoWaitMessageQueue;

/**
 * 睡眠间隔的循环线程管理类
 * 获取对象List
 * @author lcb
 */
public abstract class AbstractListCycleSleepThread<T> extends AbstractRecvDriveSleepThread{
	private NoWaitMessageQueue<T> noWaitMessageQueue;
	
	@Override
	protected Object getRecvMsg() {
		Collection<T> messageList = noWaitMessageQueue.getMsgColl();
		if(DataDetUtils.isCollectionEmpty(messageList)){
			return null;
		}else{
			return messageList;
		}
	}
	
	@SuppressWarnings("unchecked")
	@Override
	protected void trans2Imp(Object object) {
		process((Collection<T>)object);
	}
	
	/**
	 * 处理接收到的结果数组
	 * @param resultList
	 */
	protected abstract void process(Collection<T> messageList);
	
	/**
	 * 设置无等待队列对象
	 * @param noWaitMessageQueue 无等待队列对象
	 */
	public void setNoWaitMessageQueue(NoWaitMessageQueue<T> noWaitMessageQueue) {
		this.noWaitMessageQueue = noWaitMessageQueue;
	}
}
